package com.stockz.core.launch;

import com.stockz.core.dao.JpaUtil;
import com.stockz.core.util.SpringUtil;
import com.stockz.downloaderx.DownloadManager;

public class DatabaseShutdownHook extends Thread {
	
	@Override
	public void run() {
		DownloadManager downloadManager = SpringUtil.getApplicationContext().getBean(DownloadManager.class);
		downloadManager.cancelAllDownloads();
		JpaUtil jpaUtil = SpringUtil.getApplicationContext().getBean(JpaUtil.class);
		jpaUtil.shutdownDatabase();
	}
}
